package spring.angularjs.dao;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import spring.angularjs.domain.User;

@Repository
public class UserDAOImpl implements UserDAO {
	
	@Autowired
	private SessionFactory sessionFactory;

	@Override
	public User getUserAuthentication(String iduser) {
		List<User> list = null;
		Query query = sessionFactory
				.getCurrentSession()
				.createQuery(
						"Select a from User a where a.iduser = :m");
		query.setParameter("m", iduser);
		list = query.list();
		if (list.size() > 0) {
			return list.get(0);
		} else {
			return null;
		}
	}

}
